﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _01.策略模式.Enums;
using _01.策略模式.Factories;
using _01.策略模式.Strategies;

namespace _01.策略模式.Entities
{
    public class Product : BaseEntity
    {
        private decimal _sellingPrice;

        public Product() { }

        public Product(string name, decimal price)
        {
            this.Price = price;
            this._sellingPrice = price;
        }

        public string Name { get; set; }
        public decimal Price { get; internal set; }

        public decimal SellingPrice
        {
            get { return _sellingPrice; }
        }

        public void ApplyDiscount(CustomerType customerType)
        {
            IDiscountStrategy discountStrategy = DiscountFactory.GetDiscountStrategy(customerType);
            this._sellingPrice = discountStrategy.ApplyProductDiscount(this.Price);
        }
    }
}
